home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / MATH / NRPAS13 / SPLIE2.DEM < prev    next >
Text File  |  1991-04-29  |  1KB  |  52 lines

  1. PROGRAM d3r12(input,output);
  2. (* driver for routine SPLIE2 *)
  3. CONST
  4.    m=10;
  5.    n=10;
  6. TYPE
  7.    glnarray = ARRAY [1..n] OF real;
  8.    glmbyn = ARRAY [1..m,1..n] OF real;
  9. VAR
  10.    i,j : integer;
  11.    x1x2 : real;
  12.    x1,x2 : glnarray;
  13.    y,y2 : glmbyn;
  14.  
  15. (*$I MODFILE.PAS *)
  16. (*$I SPLINE.PAS *)
  17.  
  18. (*$I SPLIE2.PAS *)
  19.  
  20. BEGIN
  21.    FOR i := 1 to m DO BEGIN
  22.       x1[i] := 0.2*i
  23.    END;
  24.    FOR i := 1 to n DO BEGIN
  25.       x2[i] := 0.2*i
  26.    END;
  27.    FOR i := 1 to m DO BEGIN
  28.       FOR j := 1 to n DO BEGIN
  29.          x1x2 := x1[i]*x2[j];
  30.          y[i,j] := sqr(x1x2)
  31.       END
  32.    END;
  33.    splie2(x1,x2,y,m,n,y2);
  34.    writeln;
  35.    writeln('second derivatives from SPLIE2');
  36.    writeln('natural spline assumed');
  37.    FOR i := 1 to 5 DO BEGIN
  38.       FOR j := 1 to 5 DO write(y2[i,j]:12:6);
  39.       writeln
  40.    END;
  41.    writeln;
  42.    writeln('actual second derivatives');
  43.    FOR i := 1 to 5 DO BEGIN
  44.       FOR j := 1 to 5 DO BEGIN
  45.          x1x2 := x1[i]*x2[i];
  46.          y2[i,j] := 2.0*sqr(x1[i])
  47.       END;
  48.       FOR j := 1 to 5 DO write(y2[i,j]:12:6);
  49.       writeln
  50.    END
  51. END.
  52.